package org.su.webadapter.velocity;

import org.su.generalmvc.core.IXsshApplicationContext;
import org.su.generalmvc.core.InitialContext;
import org.apache.velocity.app.Velocity;

import java.util.Properties;

public class VelocityConfig {

	
	/**
	 * 程序默认velocity配置
	 * @return
	 */
	public static Properties getDefualtConfig(){
		IXsshApplicationContext applicationContext = InitialContext.getInstance().getContext();
		Properties p = new Properties();
		p.setProperty(Velocity.RUNTIME_LOG, "velocity.log");
		p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "/WEB-INF");
		p.setProperty(Velocity.FILE_RESOURCE_LOADER_CACHE, "true");
		p.setProperty("file.resource.loader.modificationCheckInterval", "3600");
		p.setProperty(Velocity.RESOURCE_LOADER, "file");
		p.setProperty("file.resource.loader.class",
				"org.apache.velocity.tools.view.servlet.WebappLoader");
		p.setProperty(Velocity.INPUT_ENCODING, applicationContext.getConfig()
				.getEncoding());
		p.setProperty(Velocity.OUTPUT_ENCODING, applicationContext.getConfig()
				.getEncoding());
	//	p.setProperty(Velocity.EVENTHANDLER_REFERENCEINSERTION,
	//			"org.apache.velocity.app.event.implement.EscapeHtmlReference");
	//	p.setProperty("eventhandler.escape.html.match", "$X");
		return p;
	}
	
}
